layui.use(['table','element', 'layer'], function () {
    var table = layui.table;
    var layer = layui.layer;

    var branchTable = table.render({
        elem: '#stockTable'
        // ,height: 315
        // ,url: baseURL + 'sys/branch/list' //数据接口
        , page: true //开启分页


        , cols: [[ //表头
            {field: 'toolNum', title: '机具编号', sort: true,width:'15%'}
            , {field: 'toolType', title: '机具型号', width: '15%'}
            , {field: 'toolBatch', title: '入库批次号', width: '15%'}
            , {field: 'toolStatus', title: '机具状态', width: '15%'}
            , {field: 'toolOperate', title: '操作人', width: '10%'}
            , {field: 'toolRemark', title: '备注', width: '15%'}
            , {field: 'toolTime', title: '入库时间' , width: '15%'}
        ]]

        , data: [{
            "toolNum": "21000092"
            , "toolType": "智能POS"
            , "toolBatch": "A0003"
            , "toolStatus": "正常"
            , "toolOperate": "admin"
            , "toolRemark": "最新型号"
            , "toolTime": "2018-01-08"
        }, {
            "toolNum": "21000093"
            , "toolType": "智能POS"
            , "toolBatch": "A0003"
            , "toolStatus": "正常"
            , "toolOperate": "admin"
            , "toolRemark": "最新型号"
            , "toolTime": "2018-01-08"
        },{
            "toolNum": "21000094"
            , "toolType": "智能POS"
            , "toolBatch": "A0003"
            , "toolStatus": "正常"
            , "toolOperate": "admin"
            , "toolRemark": "最新型号"
            , "toolTime": "2018-01-08"
        },{
            "toolNum": "21000095"
            , "toolType": "智能POS"
            , "toolBatch": "A0003"
            , "toolStatus": "正常"
            , "toolOperate": "admin"
            , "toolRemark": "最新型号"
            , "toolTime": "2018-01-08"
        }, {
            "toolNum": "21000096"
            , "toolType": "智能POS"
            , "toolBatch": "A0003"
            , "toolStatus": "正常"
            , "toolOperate": "admin"
            , "toolRemark": "最新型号"
            , "toolTime": "2018-01-08"
        }, {
            "toolNum": "21000097"
            , "toolType": "智能POS"
            , "toolBatch": "A0003"
            , "toolStatus": "正常"
            , "toolOperate": "admin"
            , "toolRemark": "最新型号"
            , "toolTime": "2018-01-08"
        }]

    });

    var branchTable = table.render({
        elem: '#useTable'
        // ,height: 315
        // ,url: baseURL + 'sys/branch/list' //数据接口
        , page: true //开启分页


        , cols: [[ //表头
            {field: 'toolNum', title: '机具编号', sort: true, fixed: 'left'}
            , {field: 'toolType', title: '机具型号', minWidth: '100'}
            , {field: 'clientName', title: '商家名称', minWidth: '90'}
            , {field: 'clientNum', title: '商家编号', minWidth: '90'}
            , {field: 'toolStatus', title: '状态', minWidth: '90'}
            , {field: 'toolRemark', title: '客户经理', minWidth: '90'}
            , {field: 'toolTime', title: '申领时间', minWidth: '90'}
            , {fixed: 'right', width: 178, title: '操作',align: 'center', toolbar: '#barDemo'}
        ]]

        , data: [{
            "toolNum": "21000092"
            , "toolType": "智能POS"
            , "clientName": "肯德基"
            , "clientNum": "21000092"
            , "toolStatus": "正常"
            , "toolRemark": "最新型号"
            , "toolTime": "2018-01-08"
        }, {
            "toolNum": "21000092"
            , "toolType": "智能POS"
            , "clientName": "肯德基"
            , "clientNum": "21000092"
            , "toolStatus": "正常"
            , "toolRemark": "最新型号"
            , "toolTime": "2018-01-08"
        },
            {
                "toolNum": "21000092"
                , "toolType": "智能POS"
                , "clientName": "肯德基"
                , "clientNum": "21000092"
                , "toolStatus": "正常"
                , "toolRemark": "最新型号"
                , "toolTime": "2018-01-08"
            },
            {
                "toolNum": "21000092"
                , "toolType": "智能POS"
                , "clientName": "肯德基"
                , "clientNum": "21000092"
                , "toolStatus": "正常"
                , "toolRemark": "最新型号"
                , "toolTime": "2018-01-08"
            },
            {
                "toolNum": "21000092"
                , "toolType": "智能POS"
                , "clientName": "肯德基"
                , "clientNum": "21000092"
                , "toolStatus": "正常"
                , "toolRemark": "最新型号"
                , "toolTime": "2018-01-08"
            },
            {
                "toolNum": "21000092"
                , "toolType": "智能POS"
                , "clientName": "肯德基"
                , "clientNum": "21000092"
                , "toolStatus": "正常"
                , "toolRemark": "最新型号"
                , "toolTime": "2018-01-08"
            },
            {
                "toolNum": "21000092"
                , "toolType": "智能POS"
                , "clientName": "肯德基"
                , "clientNum": "21000092"
                , "toolStatus": "正常"
                , "toolRemark": "最新型号"
                , "toolTime": "2018-01-08"
            }]

    });
    //监听工具条
    table.on('tool(branchTableFilter)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var data = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        var tr = obj.tr; //获得当前行 tr 的DOM对象

        if (layEvent === 'detail') { //查看
            window.location = '../toolmanage/toolSearch-detail.html'
            //$.post('merchant-detail.html', function (data) {
            //    layer.open({
            //        type: 1,
            //        area: ['1000px', '460px'],
            //        content: data
            //    });
            //}, 'html');
        }
    });





});